package com.orie.librarybase.utils;

import android.content.Context;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.orie.librarybase.R;

/**
 * 验证码倒计时工具类
 */
public class CountDownTimerUtils extends CountDownTimer {
    private TextView mView;
    private Context mContext;
    public CountDownTimerUtils(Context mContext, TextView view, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        this.mView=view;
        this.mContext=mContext;
        mView.setClickable(false);  //设置不可点击
    }

    @Override
    public void onTick(long millisUntilFinished) {
      //  mTextView.setBackgroundResource(R.drawable.bg_identify_code_press);//设置按钮为灰色(不可点击)
        mView.setText("重新发送("+millisUntilFinished/1000+")秒");

        //设置按钮上的文字，获取截取设置为灰色
        mView.setTextColor(Color.parseColor("#FFFFFF"));

    }
    @Override
    public void onFinish() {
        mView.setText("重新获取验证码");
        mView.setClickable(true);//重新获得点击
        mView.setTextColor(Color.parseColor("#FFFFFF"));
    }
}